<% if (locking) { %>
  // Locking plugin
  bool private locked = false;
  modifier locking {
    require(!locked);
    locked = true;
    _;
    locked = false;
  } <% } %> <% if (counter) { %>
  // Transition Counter plugin
  uint private transitionCounter = 0;
  modifier transitionCounting(uint nextTransitionNumber) {
    require(nextTransitionNumber == transitionCounter);
    transitionCounter +=1;
    _;
  } <% } %> <% if (timedTransitions) { %>
  // Timed Transitions plugin
  modifier timedTransitions {
 <%for(var i = 0;i < timedTrans.length; i += 1) {%>
  if ((state == States.<%-timedTrans[i].src%>) <%if (timedTrans[i].time) {%>
      && (now >= creationTime + <%-timedTrans[i].time%>) <% } %> <%if (timedTrans[i].guards) {%>
      && (<%-timedTrans[i].guards%>)) <% } %> ) {   <%-timedTrans[i].statements%>
      state = States.<%-timedTrans[i].dst%>;
    } <% } %>
   _;
  }
<% } %> <% if (accessControl) { %>
  // Access Control plugin
  mapping(address => bool) private isAdmin;
  uint private numAdmins = 1;

  function <%- name %>() {
    isAdmin[msg.sender] = true;
  }

  modifier onlyAdmin {
    require(isAdmin[msg.sender]);
    _;
  }

  function addAdmin(address admin) onlyAdmin {
    require(!isAdmin[admin]);
    isAdmin[admin] = true;
    numAdmins +=1;
  }

  function removeAdmin(address admin) onlyAdmin {
    require(isAdmin[admin]);
    require(numAdmins > 1);
    isAdmin[admin] = false;
    numAdmins -= 1;
  } <% } %>
<% if (events) { %>
  // Events plugin <%for(var i = 0;i < transitions.length; i += 1) {%> <%if (transitions[i].tags.includes("event")) {%>
    event Event<%-transition[i].name%>;
    modifier event<%-transition[i].name%> {
      _;
      Event<%-transition[i].name%>();
    } <% } %><% } %>
<% } %>